package com.stwyj.sbd.config.exception;

import com.stwyj.sbd.common.AppErrors;

/**
 *<p>
 * 运行时异常定义
 *</p>
 *
 * @author stwyj
 * @since 2018/11/29
 */
public class AppException extends RuntimeException {


    private static final long serialVersionUID = -2285739833204427158L;

    public static final Integer DEFAULT_ERROR_CODE = 1;
    public static final String DEFAULT_ERROR_MSG = "系统错误";

    private Integer code;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public AppException(Integer code, String message) {
        super(message, null);
        this.code = code;
    }

    public AppException(Integer code, String message, Throwable t) {
        super(message, t);
        this.code = code;
    }

    public AppException(Integer code) {
        super(AppErrors.message(code), null);
        this.code = code;
    }

    public AppException(Integer code, Throwable t) {
        super(AppErrors.message(code), t);
        this.code = code;
    }

    public AppException(AppErrors appErrors) {
        super(appErrors.message(), null);
        this.code = appErrors.code();
    }

    public AppException(AppErrors appErrors, Throwable t) {
        super(appErrors.message(), t);
        this.code = appErrors.code();
    }
}
